from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token

from apps.users import views
from rest_framework.routers import DefaultRouter

from users.views import AddressViewSet

urlpatterns = [
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.RegisterUsernameCountAPIView.as_view(),
        name='usernamecount'),
    url(r'^phones/(?P<mobile>1[345789]\d{9})/count/$', views.RegisterPhoneCountAPIView.as_view(), name='phonecount'),
    url(r'^$', views.RegisterCreateView.as_view()),
    # 登录获取token的视图
    url(r'auths/', views.UserAuthorizationView.as_view(), name='auths'),

    # 进入用户中心的视图
    url(r'^infos/$', views.UserDetailView.as_view(), name='detail'),

    # 发送邮件
    url(r'^emails/$', views.EmailView.as_view(), name='send_mail'),

    # 激活邮箱
    url(r'^emails/verification/$', views.VerificationEmailView.as_view()),

    # 用户历史记录
    url(r'^browerhistories/$',views.UserHistoryView.as_view(),name='history'),


]

router = DefaultRouter()
router.register(r'addresses', AddressViewSet, base_name='')
urlpatterns += router.urls
